home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / mis_cnvt / ntx2dbf / ntxcat.prg < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.9 KB  |  89 lines

  1. CLEAR ALL
  2. CLEAR
  3. SET CONFIRM ON
  4. *** display title box
  5. LINE1="ADD DATABSE NAME TO ALL NTX'S IN CURRENT DIRECTORY"
  6. LINE2='TODAY IS '+NAMEDATE()
  7. CENTERBOX(2,LINE1,LINE2)
  8.  
  9. *** get list of .ntx's in currrent directory & put into dbf file
  10. run dir *.ntx>NTXS.TXT
  11. select 1
  12. if file("NTXS.DBF")
  13.    use NTXS
  14.    zap 
  15. else && create new database file ntxs.dbf
  16.    create prg_stru
  17.    use prg_stru
  18.    append blank 
  19.    replace field_name with "NAME",field_type with "C",field_len with 8
  20.    close databases 
  21.    create NTXS from prg_stru
  22.    erase prg_stru.dbf
  23.    use NTXS
  24. endif 
  25. append from NTXS.TXT SDF
  26. delete for NAME=" "
  27. pack 
  28. go top 
  29.  
  30. DO WHILE .NOT. EOF()
  31. *** display index file name & prompt for databse name to be inserted
  32. NTX_NAME=TRIM(NAME)
  33. LINE1='CATALOGING NTX FILE: '+NTX_NAME
  34. @6,0 CLEAR
  35. CENTERBOX(7,LINE1)
  36. DBF_NAME=SPAC(8)
  37. @10,10 SAY 'ENTER DATABASE NAME TO BE INSERTED' GET DBF_NAME
  38. READ
  39.  
  40. *** open index file
  41. inHANDLE = fopen("&ntx_name..ntx")
  42. if ferror() <> 0
  43.    @12,10 SAY 'ERROR OPENING FILE: '+NTX_NAME+'.NTX'
  44.    WAIT
  45.    CLOSE DATABASES
  46.    clear screen
  47.    RETURN
  48. endif 
  49.  
  50. *** set up temporary output file
  51. outhandle= fcreate('tmp.fil')
  52.  
  53. *** get total file length
  54. FLEN = fseek(inHANDLE,0,2)
  55.  
  56. *** reset file pointer to beginning
  57. fseek(inHANDLE,0)
  58.  
  59. *** read 1st 1008 bytes & put into buffer1
  60. block=1008
  61. buffer=spac(1008)
  62. fread(inHANDLE,@buffer,block)
  63. OBUFFER = buffer+PAD(DBF_NAME,8)
  64.  
  65. *** move file pointer by 8 bytes & read rest of file into buffer2
  66. fseek(inhandle,8,1)
  67. block=flen-1016
  68. buffer=spac(flen-1016)
  69. fread(inhandle,@buffer,block)
  70.  
  71. *** set string for output file
  72. obuffer=Obuffer+buffer
  73.  
  74. *** write string to output file
  75. fwrite(outhandle,obuffer)
  76.  
  77. *** close input & output files
  78. fclose(inhandle)
  79. fclose(outhandle)
  80.  
  81. *** rename tmp.fil to original name
  82. erase &ntx_name..ntx
  83. rename tmp.fil to &ntx_name..ntx
  84.  
  85. SKIP
  86. ENDDO
  87. CLEAR SCREEN
  88. CLOSE DATABASES
  89. RETURN